<template>
  <div>
    <EvDrawer
      :drawer="drawer"
      :title="drawerTitle"
      size="45%"
      @handleClose="handleClose"
      @handleCancel="handleCancel"
      @handleConfirm="handleConfirm"
      :showConfirm="true"
    >
      <EvBuilder ref="builder" :layoutModelCode="layoutModelCode" @ready="ready"></EvBuilder>
    </EvDrawer>
  </div>
</template>
<script>
import EvBuilder from "@/components/EvBuilder";
export default {
  props: {
    drawerTitle: {
      type: String,
      default: "title",
    },
  },
  components: {
    EvBuilder,
  },
  data() {
    return {
      drawer: false,
      form: {},
      rule: [],
      row: {},
      layoutModelCode: "",
    };
  },
  methods: {
    open(row) {
      try {
        this.layoutModelCode = row.code;
        this.row = row;
        this.drawer = true;
      } catch (error) {
        console.log(error);
      }
    },
    ready(rule) {
      console.log(rule);
      this.rule = rule;
      this.setValues();
    },
    setValues() {
      //设置值
    },
    handleCancel() {
      this.drawer = false;
    },
    handleClose() {
      this.drawer = false;
    },
    handleConfirm() {
      // 获取值
      const form = this.$refs.builder.getValues();
      console.log(form);
      this.drawer = false;
    },
  },
};
</script>
<style lang="scss" scoped>
.partTitle {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  margin: 12px 0;
}
</style>